from Hex import *

class HexMap:

    def __init__(self, size=128):
        self.map = {}
        self.size = size

    def CreateHex(self, x, y, z, scale):
        self.map[(x,y)] = Hex(x, y, z, scale)

    def Get(self, x, y):
        return self.map[(x,y)]

    def Set(self, x, y, value):
        self.map[(x,y)] = value

    def HasUnits(self, x, y):
        return self.map[(x,y)].hasUnits

    def IsAI(self, x, y):
        return self.map[(x,y)].isAI;

    def CalculateDistance(fromx, fromy, destx, desty):
        distance = abs(fromy - desty)
        if(distance//2<abs(fromx-destx)):
            distance += abs(fromx-destx)-(distance+1)//2
        return distance